#include "ZigbusItemFactory.h"
#include <QDebug>

ZigbusItem* ZigbusItemFactory::duplicate(ZigbusItem* src)
{
    if(ZigbusAddressingType* type = dynamic_cast<ZigbusAddressingType*>(src)) {
        return new ZigbusAddressingType(*type);
    }
    if(ZigbusAddressNeed* need = dynamic_cast<ZigbusAddressNeed*>(src)) {
        return new ZigbusAddressNeed(*need);
    }
    if(ZigbusAnalogicReference* ref = dynamic_cast<ZigbusAnalogicReference*>(src)) {
        return new ZigbusAnalogicReference(*ref);
    }
    if(ZigbusHeatingFunction* func = dynamic_cast<ZigbusHeatingFunction*>(src)) {
        return new ZigbusHeatingFunction(*func);
    }
    if(ZigbusHygroItem* hygro = dynamic_cast<ZigbusHygroItem*>(src)) {
        return new ZigbusHygroItem(*hygro);
    }
    if(ZigbusIO* io = dynamic_cast<ZigbusIO*>(src)) {
        return new ZigbusIO(*io);
    }
    if(ZigbusIsAnalogicItem* isanalog = dynamic_cast<ZigbusIsAnalogicItem*>(src)) {
        return new ZigbusIsAnalogicItem(*isanalog);
    }
    if(ZigbusMeteoType* type = dynamic_cast<ZigbusMeteoType*>(src)) {
        return new ZigbusMeteoType(*type);
    }
    if(ZigbusModuleId* id = dynamic_cast<ZigbusModuleId*>(src)) {
        return new ZigbusModuleId(*id);
    }
    if(ZigbusNetworkId* id = dynamic_cast<ZigbusNetworkId*>(src)) {
        return new ZigbusNetworkId(*id);
    }
    if(ZigbusNumericIniState* inistate = dynamic_cast<ZigbusNumericIniState*>(src)) {
        return new ZigbusNumericIniState(*inistate);
    }
    if(ZigbusOrder* order = dynamic_cast<ZigbusOrder*>(src)) {
        return new ZigbusOrder(*order);
    }
    if(ZigbusOrderDirection* direction = dynamic_cast<ZigbusOrderDirection*>(src)) {
        return new ZigbusOrderDirection(*direction);
    }
    if(ZigbusPwmValue* pwm = dynamic_cast<ZigbusPwmValue*>(src)) {
        return new ZigbusPwmValue(*pwm);
    }
    if(ZigbusServoPosition* pos = dynamic_cast<ZigbusServoPosition*>(src)) {
        return new ZigbusServoPosition(*pos);
    }
    if(ZigbusTemperatureItem* temp = dynamic_cast<ZigbusTemperatureItem*>(src)) {
        return new ZigbusTemperatureItem(*temp);
    }
    if(ZigbusTieActivItem* activ = dynamic_cast<ZigbusTieActivItem*>(src)) {
        return new ZigbusTieActivItem(*activ);
    }
    if(ZigbusTieRevertItem *revert = dynamic_cast<ZigbusTieRevertItem*>(src)) {
        return new ZigbusTieRevertItem(*revert);
    }
    if(ZigbusTimeItem* time = dynamic_cast<ZigbusTimeItem*>(src)) {
        return new ZigbusTimeItem(*time);
    }
    if(ZigbusType* type = dynamic_cast<ZigbusType*>(src)) {
        return new ZigbusType(*type);
    }
    return new ZigbusItem(*src);
}
